import java.util.concurrent.TimeUnit;

/**
 * wait(0)和sleep(0)
 */
public class WaitDemo7 {
    public static void main(String[] args) throws InterruptedException {
        Object lock=new Object();
      Thread t1=new Thread(()->{
          synchronized (lock){
              System.out.println("线程1：开始执行");
              try {
                  lock.wait(10);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              System.out.println("线程1：结束执行");
          }
      },"wait(0)");
      t1.start();

     Thread t2=new Thread(()->{
         System.out.println("线程2：开始执行 ");
         try {
             Thread.sleep(10);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
         System.out.println("线程2：执行结束 ");
     },"sleep(0)");
     t2.start();
    }
}
